#include<stdio.h>
int main()
{
	int s[1000],T,n,x,len,i,er;
	scanf("%d",&T);
	while(T--)
	{
		x=0;
		er=1;
		scanf("%d",&n);
		while(n!=0)
		{
			s[x++]=n%2;
			n/=2;
		}
		len=x-1;
		x=0;
		for(i=len;i>=0;i--)
		{
			x+=s[i]*er;
			er*=2;
		}
		printf("%d\n",x);
	}
	return 0;
}
